	<!--{*部分 - 品牌列表*}-->
	<?php
	$RANK   = AutoCategory::getCache(AutoCategory::TYPE_RANK);
	$brands  = Auto::brands($RANK);
	$LETTER = Auto::uniqueLetter($brands);
	$BRANDS = array();
	foreach ($brands as $bid => $_brand) {
		if (isset($BRANDS[$_brand['letter']])) {
			$BRANDS[$_brand['letter']][$bid] = $_brand;
		} else {
			$BRANDS[$_brand['letter']] = array();
			$BRANDS[$_brand['letter']][$bid] = $_brand;
		}
	}
	?>
	<!--首字母筛选start-->
	<div id="js-filter-initials" class="filter-initial fn-clear">
		<ul>
			{php $word = range('A', 'Z')}
			{loop $word $alf}
			<li {if !in_array($alf,$LETTER)} class="unselect"{/if}>{strtoupper($alf)}</li>
			{/loop}
		</ul>
	</div>
	<!--首字母筛选 end-->

	<!--车型列表-->
	<div id="js-auto-brands" class="brands-list">
        {loop $BRANDS $letter $brands}
        <dl id="letter{$letter}" class="fn-clear">
			<dt>{$letter}</dt>
			{loop $brands $bid $_brand}
			<dd {if $_brand['arid'] == $brandId }id="js-cur-brand"{/if}>
				<a href="{url('auto/brand', 'brandId='.$_brand['arid'])}">{$_brand[name]}</a>
				{if $_brand['arid'] == $brandId }
				<div class="sub-brands-list">
					{loop $manusAndCars $manuid $manu}
					{if $manuid == 'children'}{php continue;}{/if}
					<dl>
						<dt><a href="{url('auto/brand', 'manufactorId='.$manu['arid'])}">{$manu[name]}</a></dt>
						{loop $manusAndCars[children][$manuid] $car}
						<dd><a href="{url('auto/car', 'carid='.$car['arid'])}">{$car[name]}</a></dd>
						{/loop}
					</dl>
					{/loop}
				</div>
				{/if}
			</dd>
			{/loop}
        </dl>
		{/loop}
		<dl id="js-brand-bot"></dl>
	</div>
	<!--车型列表 end-->
    <script type="text/javascript">
        seajs.use(['$'],function($){
            //品牌首字母选择
            var $alif = $("#js-filter-initials"),
                    $brands = $("div#js-auto-brands");
            $alif.find("li:not('.unselect')").click(function() {
                $(this).addClass("selected").siblings().removeClass("selected");
                var alif = $(this).text(),
                        curBrand = "#letter" + alif,
                        scrollPos = 0,
                        prevNum = $(curBrand).index(),
                        i= 0;

                for (i = 0; i < prevNum; i++) {
                    scrollPos += $(curBrand).siblings().eq(i).height() + 1;
                }
                $brands.scrollTop(scrollPos);
                if ($brands.scrollTop() < scrollPos) {
                    var $brandBot = $("#js-brand-bot");
                    var botH = scrollPos - $brands.scrollTop() + $brandBot.height();
                    $brandBot.height(botH);
                    $brands.scrollTop(scrollPos);
                }
            });

            //定位当前品牌
            var $brands = $("div#js-auto-brands"),
                    $scrollTo = $("#js-cur-brand");
            if ($scrollTo.length > 0) {
                //显示当前品牌下的子品牌
                $scrollTo.find(".sub-brands-list").removeClass("fn-hide");
                //当前品牌首字母选中
                var brandAlif = $scrollTo.siblings("dt").text(),
                        $alif = $("#js-filter-initials").find("li");
                for (var i = 0, max = $alif.length; i < max; i++) {
                    if ($alif.eq(i).text() == brandAlif) {
                        $alif.eq(i).addClass("selected").siblings().removeClass("selected");
                        break;
                    }
                }
                //滚动条滚动到选择品牌的位置
                var scrollPos = $scrollTo.offset().top - $brands.offset().top;
                $brands.scrollTop(scrollPos);
                if ($brands.scrollTop() < scrollPos) {
                    var $brandBot = $("#js-brand-bot"),
                            botH = scrollPos - $brands.scrollTop() + $brandBot.height();
                    $brandBot.height(botH);
                    $brands.scrollTop(scrollPos);
                }
            }

            //高度
            var winH = $(window).height(),
                    winTop,
                    $brand = $("#js-auto-brands"),
                    brandH,
                    $autoLeft = $("div.auto-filter-left"),
                    autoLeftTop;
            if ($autoLeft.length > 0) {
                autoLeftTop = $autoLeft.offset().top;
            }

            //固定div
            function fix() {
                winTop = $(window).scrollTop()+30;
                brandH = winH - 267 + winTop;
                if (winTop < autoLeftTop) {
                    $brand.height(brandH);
                    $("div.auto-filter-left").attr("style", "position:static");
                } else {
                    $brand.height(winH - 78);
                    $("div.auto-filter-left").attr("style", "position: fixed; top:30px;_position: absolute; _top:" + winTop + "px;");
                }
            }
            $(window).resize(function(e) {
                winH = $(window).height();
                fix();
            });
            $(window).load(function(e) {
                fix();
            });
            $(window).scroll(function(e) {
                fix();
            });
        });
    </script>

<!--筛选页左侧 end-->


